<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- /fasttmp/mkdist-qt-4.3.5-1211793125/qtopia-core-opensource-src-4.3.5/src/corelib/kernel/qabstracteventdispatcher.cpp -->
<head>
  <title>Qt 4.3: QAbstractEventDispatcher Class Reference</title>
  <link href="classic.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left" valign="top" width="32"><a href="http://www.trolltech.com/products/qt"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></a></td>
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a>&nbsp;&middot; <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a>&nbsp;&middot; <a href="modules.html"><font color="#004faf">Modules</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">Functions</font></a></td>
<td align="right" valign="top" width="230"><a href="http://www.trolltech.com"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></a></td></tr></table><h1 align="center">QAbstractEventDispatcher Class Reference<br /><sup><sup>[<a href="qtcore.html">QtCore</a> module]</sup></sup></h1>
<p>The QAbstractEventDispatcher class provides an interface to manage Qt's event queue. <a href="#details">More...</a></p>
<pre> #include &lt;QAbstractEventDispatcher&gt;</pre><p>Inherits <a href="qobject.html">QObject</a>.</p>
<ul>
<li><a href="qabstracteventdispatcher-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="public-types"></a>
<h3>Public Types</h3>
<ul>
<li><div class="fn"/>typedef <b><a href="qabstracteventdispatcher.html#EventFilter-typedef">EventFilter</a></b></li>
<li><div class="fn"/>typedef <b><a href="qabstracteventdispatcher.html#TimerInfo-typedef">TimerInfo</a></b></li>
</ul>
<a name="public-functions"></a>
<h3>Public Functions</h3>
<ul>
<li><div class="fn"/><b><a href="qabstracteventdispatcher.html#QAbstractEventDispatcher">QAbstractEventDispatcher</a></b> ( QObject * <i>parent</i> = 0 )</li>
<li><div class="fn"/><b><a href="qabstracteventdispatcher.html#dtor.QAbstractEventDispatcher">~QAbstractEventDispatcher</a></b> ()</li>
<li><div class="fn"/>bool <b><a href="qabstracteventdispatcher.html#filterEvent">filterEvent</a></b> ( void * <i>message</i> )</li>
<li><div class="fn"/>virtual void <b><a href="qabstracteventdispatcher.html#flush">flush</a></b> () = 0</li>
<li><div class="fn"/>virtual bool <b><a href="qabstracteventdispatcher.html#hasPendingEvents">hasPendingEvents</a></b> () = 0</li>
<li><div class="fn"/>virtual void <b><a href="qabstracteventdispatcher.html#interrupt">interrupt</a></b> () = 0</li>
<li><div class="fn"/>virtual bool <b><a href="qabstracteventdispatcher.html#processEvents">processEvents</a></b> ( QEventLoop::ProcessEventsFlags <i>flags</i> ) = 0</li>
<li><div class="fn"/>virtual void <b><a href="qabstracteventdispatcher.html#registerSocketNotifier">registerSocketNotifier</a></b> ( QSocketNotifier * <i>notifier</i> ) = 0</li>
<li><div class="fn"/>int <b><a href="qabstracteventdispatcher.html#registerTimer">registerTimer</a></b> ( int <i>interval</i>, QObject * <i>object</i> )</li>
<li><div class="fn"/>virtual void <b><a href="qabstracteventdispatcher.html#registerTimer-2">registerTimer</a></b> ( int <i>timerId</i>, int <i>interval</i>, QObject * <i>object</i> ) = 0</li>
<li><div class="fn"/>virtual QList&lt;TimerInfo&gt; <b><a href="qabstracteventdispatcher.html#registeredTimers">registeredTimers</a></b> ( QObject * <i>object</i> ) const = 0</li>
<li><div class="fn"/>EventFilter <b><a href="qabstracteventdispatcher.html#setEventFilter">setEventFilter</a></b> ( EventFilter <i>filter</i> )</li>
<li><div class="fn"/>virtual void <b><a href="qabstracteventdispatcher.html#unregisterSocketNotifier">unregisterSocketNotifier</a></b> ( QSocketNotifier * <i>notifier</i> ) = 0</li>
<li><div class="fn"/>virtual bool <b><a href="qabstracteventdispatcher.html#unregisterTimer">unregisterTimer</a></b> ( int <i>timerId</i> ) = 0</li>
<li><div class="fn"/>virtual bool <b><a href="qabstracteventdispatcher.html#unregisterTimers">unregisterTimers</a></b> ( QObject * <i>object</i> ) = 0</li>
<li><div class="fn"/>virtual void <b><a href="qabstracteventdispatcher.html#wakeUp">wakeUp</a></b> () = 0</li>
</ul>
<ul>
<li><div class="fn"/>29 public functions inherited from <a href="qobject.html#public-functions">QObject</a></li>
</ul>
<a name="signals"></a>
<h3>Signals</h3>
<ul>
<li><div class="fn"/>void <b><a href="qabstracteventdispatcher.html#aboutToBlock">aboutToBlock</a></b> ()</li>
<li><div class="fn"/>void <b><a href="qabstracteventdispatcher.html#awake">awake</a></b> ()</li>
</ul>
<ul>
<li><div class="fn"/>1 signal inherited from <a href="qobject.html#signals">QObject</a></li>
</ul>
<a name="static-public-members"></a>
<h3>Static Public Members</h3>
<ul>
<li><div class="fn"/>QAbstractEventDispatcher * <b><a href="qabstracteventdispatcher.html#instance">instance</a></b> ( QThread * <i>thread</i> = 0 )</li>
</ul>
<ul>
<li><div class="fn"/>5 static public members inherited from <a href="qobject.html#static-public-members">QObject</a></li>
</ul>
<h3>Additional Inherited Members</h3>
<ul>
<li><div class="fn"/>1 property inherited from <a href="qobject.html#properties">QObject</a></li>
<li><div class="fn"/>1 public slot inherited from <a href="qobject.html#public-slots">QObject</a></li>
<li><div class="fn"/>7 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li>
</ul>
<a name="details"></a>
<hr />
<h2>Detailed Description</h2>
<p>The QAbstractEventDispatcher class provides an interface to manage Qt's event queue.</p>
<p>An event dispatcher receives events from the window system and other sources. It then sends them to the <a href="qcoreapplication.html">QCoreApplication</a> or <a href="qapplication.html">QApplication</a> instance for processing and delivery. QAbstractEventDispatcher provides fine-grained control over event delivery.</p>
<p>For simple control of event processing use <a href="qcoreapplication.html#processEvents">QCoreApplication::processEvents</a>().</p>
<p>For finer control of the application's event loop, call <a href="qabstracteventdispatcher.html#instance">instance</a>() and call functions on the QAbstractEventDispatcher object that is returned. If you want to use your own instance of QAbstractEventDispatcher or of a QAbstractEventDispatcher subclass, you must create your instance <i>before</i> you create the <a href="qapplication.html">QApplication</a> object.</p>
<p>The main event loop is started by calling <a href="qcoreapplication.html#exec">QCoreApplication::exec</a>(), and stopped by calling <a href="qcoreapplication.html#exit">QCoreApplication::exit</a>(). Local event loops can be created using <a href="qeventloop.html">QEventLoop</a>.</p>
<p>Programs that perform long operations can call <a href="qabstracteventdispatcher.html#processEvents">processEvents</a>() with a bitwise OR combination of various <a href="qeventloop.html#ProcessEventsFlag-enum">QEventLoop::ProcessEventsFlag</a> values to control which events should be delivered.</p>
<p>QAbstractEventDispatcher also allows the integration of an external event loop with the Qt event loop. For example, the <a href="http://www.trolltech.com/products/qt/addon/solutions/">Motif Extension Qt Solution</a> includes a reimplementation of QAbstractEventDispatcher that merges Qt and Motif events together.</p>
<p>See also <a href="qeventloop.html">QEventLoop</a> and <a href="qcoreapplication.html">QCoreApplication</a>.</p>
<hr />
<h2>Member Type Documentation</h2>
<h3 class="fn"><a name="EventFilter-typedef"></a>typedef QAbstractEventDispatcher::EventFilter</h3>
<p>Typedef for a function with the signature</p>
<pre> bool myEventFilter(void *message);</pre>
<p>See also <a href="qabstracteventdispatcher.html#setEventFilter">setEventFilter</a>() and <a href="qabstracteventdispatcher.html#filterEvent">filterEvent</a>().</p>
<h3 class="fn"><a name="TimerInfo-typedef"></a>typedef QAbstractEventDispatcher::TimerInfo</h3>
<p>Typedef for <a href="qpair.html">QPair</a>&lt;int, int&gt;. The first component of the pair is the timer ID; the second component is the interval.</p>
<p>See also <a href="qabstracteventdispatcher.html#registeredTimers">registeredTimers</a>().</p>
<hr />
<h2>Member Function Documentation</h2>
<h3 class="fn"><a name="QAbstractEventDispatcher"></a>QAbstractEventDispatcher::QAbstractEventDispatcher ( <a href="qobject.html">QObject</a> * <i>parent</i> = 0 )</h3>
<p>Constructs a new event dispatcher with the given <i>parent</i>.</p>
<h3 class="fn"><a name="dtor.QAbstractEventDispatcher"></a>QAbstractEventDispatcher::~QAbstractEventDispatcher ()</h3>
<p>Destroys the event dispatcher.</p>
<h3 class="fn"><a name="aboutToBlock"></a>void QAbstractEventDispatcher::aboutToBlock ()&nbsp;&nbsp;<tt> [signal]</tt></h3>
<p>This signal is emitted before the event loop calls a function that could block.</p>
<p>See also <a href="qabstracteventdispatcher.html#awake">awake</a>().</p>
<h3 class="fn"><a name="awake"></a>void QAbstractEventDispatcher::awake ()&nbsp;&nbsp;<tt> [signal]</tt></h3>
<p>This signal is emitted after the event loop returns from a function that could block.</p>
<p>See also <a href="qabstracteventdispatcher.html#wakeUp">wakeUp</a>() and <a href="qabstracteventdispatcher.html#aboutToBlock">aboutToBlock</a>().</p>
<h3 class="fn"><a name="filterEvent"></a>bool QAbstractEventDispatcher::filterEvent ( void * <i>message</i> )</h3>
<p>Sends <i>message</i> through the event filter that was set by <a href="qabstracteventdispatcher.html#setEventFilter">setEventFilter</a>(). If no event filter has been set, this function returns false; otherwise, this function returns the result of the event filter function.</p>
<p>Subclasses of <a href="qabstracteventdispatcher.html">QAbstractEventDispatcher</a> <i>must</i> call this function for <i>all</i> messages received from the system to ensure compatibility with any extensions that may be used in the application.</p>
<p>See also <a href="qabstracteventdispatcher.html#setEventFilter">setEventFilter</a>().</p>
<h3 class="fn"><a name="flush"></a>void QAbstractEventDispatcher::flush ()&nbsp;&nbsp;<tt> [pure virtual]</tt></h3>
<p>Flushes the event queue. This normally returns almost immediately. Does nothing on platforms other than X11.</p>
<h3 class="fn"><a name="hasPendingEvents"></a>bool QAbstractEventDispatcher::hasPendingEvents ()&nbsp;&nbsp;<tt> [pure virtual]</tt></h3>
<p>Returns true if there is an event waiting; otherwise returns false.</p>
<h3 class="fn"><a name="instance"></a>QAbstractEventDispatcher * QAbstractEventDispatcher::instance ( <a href="qthread.html">QThread</a> * <i>thread</i> = 0 )&nbsp;&nbsp;<tt> [static]</tt></h3>
<p>Returns a pointer to the event dispatcher object for the specified <i>thread</i>. If <i>thread</i> is zero, the current thread is used. If no event dispatcher exists for the specified thread, this function returns 0.</p>
<p><b>Note:</b> If Qt is built without thread support, the <i>thread</i> argument is ignored.</p>
<h3 class="fn"><a name="interrupt"></a>void QAbstractEventDispatcher::interrupt ()&nbsp;&nbsp;<tt> [pure virtual]</tt></h3>
<p>Interrupts event dispatching; i.e&#x2e; the event dispatcher will return from <a href="qabstracteventdispatcher.html#processEvents">processEvents</a>() as soon as possible.</p>
<h3 class="fn"><a name="processEvents"></a>bool QAbstractEventDispatcher::processEvents ( <a href="qeventloop.html#ProcessEventsFlag-enum">QEventLoop::ProcessEventsFlags</a> <i>flags</i> )&nbsp;&nbsp;<tt> [pure virtual]</tt></h3>
<p>Processes pending events that match <i>flags</i> until there are no more events to process. Returns true if an event was processed; otherwise returns false.</p>
<p>This function is especially useful if you have a long running operation and want to show its progress without allowing user input; i.e&#x2e; by using the <a href="qeventloop.html#ProcessEventsFlag-enum">QEventLoop::ExcludeUserInputEvents</a> flag.</p>
<p>If the <a href="qeventloop.html#ProcessEventsFlag-enum">QEventLoop::WaitForMoreEvents</a> flag is set in <i>flags</i>, the behavior of this function is as follows:</p>
<ul>
<li>If events are available, this function returns after processing them.</li>
<li>If no events are available, this function will wait until more are available and return after processing newly available events.</li>
</ul>
<p>If the <a href="qeventloop.html#ProcessEventsFlag-enum">QEventLoop::WaitForMoreEvents</a> flag is not set in <i>flags</i>, and no events are available, this function will return immediately.</p>
<p><b>Note:</b> This function does not process events continuously; it returns after all available events are processed.</p>
<p>See also <a href="qabstracteventdispatcher.html#hasPendingEvents">hasPendingEvents</a>().</p>
<h3 class="fn"><a name="registerSocketNotifier"></a>void QAbstractEventDispatcher::registerSocketNotifier ( <a href="qsocketnotifier.html">QSocketNotifier</a> * <i>notifier</i> )&nbsp;&nbsp;<tt> [pure virtual]</tt></h3>
<p>Registers <i>notifier</i> with the event loop. Subclasses must implement this method to tie a socket notifier into another event loop.</p>
<h3 class="fn"><a name="registerTimer"></a>int QAbstractEventDispatcher::registerTimer ( int <i>interval</i>, <a href="qobject.html">QObject</a> * <i>object</i> )</h3>
<p>Registers a timer with the specified <i>interval</i> for the given <i>object</i>.</p>
<h3 class="fn"><a name="registerTimer-2"></a>void QAbstractEventDispatcher::registerTimer ( int <i>timerId</i>, int <i>interval</i>, <a href="qobject.html">QObject</a> * <i>object</i> )&nbsp;&nbsp;<tt> [pure virtual]</tt></h3>
<p>This is an overloaded member function, provided for convenience.</p>
<p>Register a timer with the specified <i>timerId</i> and <i>interval</i> for the given <i>object</i>.</p>
<h3 class="fn"><a name="registeredTimers"></a><a href="qlist.html">QList</a>&lt;<a href="qabstracteventdispatcher.html#TimerInfo-typedef">TimerInfo</a>&gt; QAbstractEventDispatcher::registeredTimers ( <a href="qobject.html">QObject</a> * <i>object</i> ) const&nbsp;&nbsp;<tt> [pure virtual]</tt></h3>
<p>Returns a list of registered timers for <i>object</i>. The timer ID is the first member in each pair; the interval is the second.</p>
<h3 class="fn"><a name="setEventFilter"></a><a href="qabstracteventdispatcher.html#EventFilter-typedef">EventFilter</a> QAbstractEventDispatcher::setEventFilter ( <a href="qabstracteventdispatcher.html#EventFilter-typedef">EventFilter</a> <i>filter</i> )</h3>
<p>Sets the event filter <i>filter</i>. Returns a pointer to the filter function previously defined.</p>
<p>The event filter is a function that receives all messages taken from the system event loop before the event is dispatched to the respective target. This includes messages that are not sent to Qt objects.</p>
<p>The function can return true to stop the event to be processed by Qt, or false to continue with the standard event processing.</p>
<p>Only one filter can be defined, but the filter can use the return value to call the previously set event filter. By default, no filter is set (i.e&#x2e; the function returns 0).</p>
<h3 class="fn"><a name="unregisterSocketNotifier"></a>void QAbstractEventDispatcher::unregisterSocketNotifier ( <a href="qsocketnotifier.html">QSocketNotifier</a> * <i>notifier</i> )&nbsp;&nbsp;<tt> [pure virtual]</tt></h3>
<p>Unregisters <i>notifier</i> from the event dispatcher. Subclasses must reimplement this method to tie a socket notifier into another event loop. Reimplementations must call the base implementation.</p>
<h3 class="fn"><a name="unregisterTimer"></a>bool QAbstractEventDispatcher::unregisterTimer ( int <i>timerId</i> )&nbsp;&nbsp;<tt> [pure virtual]</tt></h3>
<p>Unregisters the timer with the given <i>timerId</i>. Returns true if successful; otherwise returns false.</p>
<p>See also <a href="qabstracteventdispatcher.html#registerTimer">registerTimer</a>() and <a href="qabstracteventdispatcher.html#unregisterTimers">unregisterTimers</a>().</p>
<h3 class="fn"><a name="unregisterTimers"></a>bool QAbstractEventDispatcher::unregisterTimers ( <a href="qobject.html">QObject</a> * <i>object</i> )&nbsp;&nbsp;<tt> [pure virtual]</tt></h3>
<p>Unregisters all the timers associated with the given <i>object</i>. Returns true if all timers were successful removed; otherwise returns false.</p>
<p>See also <a href="qabstracteventdispatcher.html#unregisterTimer">unregisterTimer</a>() and <a href="qabstracteventdispatcher.html#registeredTimers">registeredTimers</a>().</p>
<h3 class="fn"><a name="wakeUp"></a>void QAbstractEventDispatcher::wakeUp ()&nbsp;&nbsp;<tt> [pure virtual]</tt></h3>
<p>Wakes up the event loop.</p>
<p><b>Note:</b> This function is <a href="threads.html#thread-safe">thread-safe</a>.</p>
<p>See also <a href="qabstracteventdispatcher.html#awake">awake</a>().</p>
<p /><address><hr /><div align="center">
<table width="100%" cellspacing="0" border="0"><tr class="address">
<td width="30%">Copyright &copy; 2008 <a href="trolltech.html">Trolltech</a></td>
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
<td width="30%" align="right"><div align="right">Qt 4.3.5</div></td>
</tr></table></div></address></body>
</html>
